<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ include file="/page/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<%@ include file="/adapter/adapter-bootstrap.jsp"%>
<link
	href="${pageContext.request.contextPath}/frontframe/easyui/themes/easyui-extend.css"
	rel="stylesheet" type="text/css" />
<script type="text/javascript">
	function save() {
		var str_data = $("#form1 input").map(function() {
			return ($(this).attr("name") + '=' + $(this).val());
		}).get().join("&");
		$.ajax({
			url : "${ctx}/appWxModelDefine/updateWxModelDefine",
			type : "POST",
			dataType : "json",
			data : str_data,
			async : false,
			success : function(data) {
				if (data.flag > 0) {
					alert("修改成功！");
					//window.location.reload();
				}
				/* 	          $.each(data, function(index, element) {
				 window.location.reload();
				 }); */
			},
			error : function() {
				alert("error");
			}
		});

	}

	function changeValue(Value, tagname) {
		document.getElementById(tagname).value = Value;
	}

	function goBack() {
		window.history.back(-1);
	}

	//用一个隐藏的input和select联动来实现选择使用挡板
	function changetype(aThis) {
		document.getElementById("sendTime").value = aThis.value;
	}
	//页面加载时给select预选值
	window.onload = function() {
		var sendTime = "${appWxModelDefine.sendTime}";
		document.getElementById("sendTime").value = sendTime;
		//给下拉框添加选项
		$("#send_time").append("<option value=\"\">实时发送</option>");
		for (var i = 0; i<=24; i++){
			$("#send_time").append("<option value=\""+ i +"\">"+i+":00</option>");
		}
		var all_options = document.getElementById("send_time").options;
		for (var i = 0; i < all_options.length; i++) {
			if (all_options[i].value == sendTime) {
				all_options[i].selected = true;
			}
		}
	}
</script>
</head>
<body>
	<div class="panel panel-default">
		<div class="panel-heading">
			<h3 class="panel-title">微信模版消息配置</h3>
		</div>
		<div class="panel-body">
			<form class="form-horizontal" role="form" id="form1">
				<div class="form-group">

					<label class="col-xs-2 control-label" for="dxModelId">菜单ID</label>
					<div class="col-xs-4">
						<input class="form-control" id="dxModelId" name="dxModelId"
							type="text" readonly="readonly" placeholder=""
							value="${appWxModelDefine.dxModelId}" />
					</div>


					<label class="col-xs-2 control-label" for="modelName">模版名</label>
					<div class="col-xs-4">
						<input class="form-control" id="modelName" name="modelName"
							type="text" placeholder=""
							value="${appWxModelDefine.modelName}" />
					</div>

				</div>
				<div class="form-group">

					<label class="col-xs-2 control-label" for="wxModelId">微信模版ID</label>
					<div class="col-xs-4">
						<input class="form-control" id="wxModelId"
							name="wxModelId" type="text" readonly="readonly"
							value="${appWxModelDefine.wxModelId}" />
					</div>


					<label class="col-xs-2 control-label" for="sendTime">发送定时</label>
					<div class="col-xs-4">
					<!--  <input class="form-control" id="sendTime" name="sendTime"
							type="hidden" /> 
						<select id="send_time"
							onchange="changetype(this)" class="form-control">
						</select>
					-->
						<input type="time"  class="form-control" id="sendTime" name="sendTime" />
					</div> 
					<input class="form-control" id="appId"
							name="appId" type="hidden" 
							value="${appWxModelDefine.appId}" />

				</div>

				<div class="form-group  text-center">
					<button type="button" class="btn btn-default" onclick="save();">保存</button>
					<button type="button" class="btn btn-default" onclick="goBack()">返回</button>
				</div>
			</form>
		</div>
	</div>

</body>
</html>
